﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Views/Shared/Site.Master" Inherits="System.Web.Mvc.ViewPage<SDT.Admin.ViewModels.OrderEditViewModels>" %>
<%@ Import Namespace="SDT.Lib.Helpers" %>
<asp:Content ID="Content1" ContentPlaceHolderID="TitleContent" runat="server">
	Chi tiết
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Header" runat="server">
   Chi tiết đơn hàng
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Toolbar" runat="server">
	<%= Html.Toolbar("Xuất hóa đơn", string.Format("/Order/Export/{0}", Model.Order.ID), "upload")%>
	<%= Html.Toolbar("Sửa", string.Format("/Order/Edit/{0}", Model.Order.ID), "edit")%>
	<%= Html.Toolbar("Xóa", string.Format("/Order/Delete/{0}", Model.Order.ID), "delete")%>
	<%= Html.Toolbar("Quay lại", "/Order", "back")%>
   
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <%if(ViewData["MessageInfo"]==null){ %>
	<fieldset>
		<legend>Chi tiết đơn hàng</legend>
		<table class="admintable">
			<tbody>
			<tr>
				<td class="key">Mã đơn hàng</td>
				<td><%= Html.Encode(Model.Order.ID) %></td>
			</tr>
			<tr>
				<td class="key">Loại đơn hàng</td>
				<td><%= Html.Encode(Model.OrderTypes[Model.Order.TypeID.HasValue?Model.Order.TypeID.Value: SDT.Lib.Common.OrderType.Normal ]) %></td>
			</tr>
			<tr>
				<td class="key">Loại hình thanh toán</td>
				<td><%= Html.Encode(Model.Order.Payment!=null? Model.Order.Payment.Name: string.Empty)%></td>
			</tr>
			<tr>
				<td class="key">Tên khách hàng</td>
				<td><%= Html.Encode(Model.Order.Customer.FullName==null || Model.Order.Customer.FullName==string.Empty? Model.Order.ReFullName: Model.Order.Customer.FullName)%></td>
			</tr>
			<tr>
				<td class="key">Mã bưu điện</td>
				<td><%= Html.Encode(Model.Order.EmsCode) %></td>
			</tr>
			<tr>
				<td class="key">Phiếu giảm giá</td>
				<td><%= Html.Encode(Model.Order.Coupon) %></td>
			</tr>
			<tr>
				<td class="key">Ngày đặt mua</td>
				<td><%= Html.Encode(string.Format("{0:dd/MM/yyyy}",Model.Order.AddDate)) %></td>
			</tr>
			<tr>
				<td class="key">Ngày mong muốn nhận hàng</td>
				<td><%= Html.Encode(string.Format("{0:dd/MM/yyyy}",Model.Order.ReceiveDate)) %></td>
			</tr>
			<tr> 
                <td class="key">Ngày giao hàng</td> 
                <td><%= Html.Encode(string.Format("{0:dd/MM/yyyy}", Model.Order.DeliveryDate))%></td> 
            </tr>
			<tr>
				<td class="key">Tình trạng</td>
				<td><%= Html.Encode(Model.OrderStatus[Model.Order.Status]) %></td>
			</tr>
			<tr>
				<td class="key">Ghi chú</td>
				<td><%= Html.Encode(Model.Order.Note) %></td>
			</tr>					
			</tbody>
		 </table>
	 </fieldset>
	 <table width="100%">
	    <tr>
	        <td width="50%">
	            <fieldset>
		            <legend>Thông tin người mua hàng</legend>
		            <table class="admintable">
			            <tbody>            			
			            <tr>
				            <td class="key">Họ tên</td>
				            <td><%= Html.Encode(Model.Order.SeFullName == null || Model.Order.SeFullName == string.Empty ? Model.Order.ReFullName : Model.Order.SeFullName)%></td>
			            </tr>
			            <tr>
				            <td class="key">Điện thoại</td>
				            <td><%= Html.Encode(Model.Order.SePhone == null || Model.Order.SePhone == string.Empty ? Model.Order.RePhone : Model.Order.SePhone)%></td>
			            </tr>
			            <tr>
				            <td class="key">Email khách hàng</td>
				            <td><%= Html.Encode(Model.Order.SeEmail == null || Model.Order.SeEmail == string.Empty ? Model.Order.ReEmail : Model.Order.SeEmail)%></td>
			            </tr>
			            <tr>
				            <td class="key">Địa chỉ khách hàng</td>
				            <td><%= Html.Encode(Model.Order.SeAddress == null || Model.Order.SeAddress == string.Empty ? Model.Order.ReAddress : Model.Order.SeAddress)%></td>
			            </tr>			
			            </tbody>
		             </table>
	             </fieldset>
	        </td>
	        <td width="50%">
	            <fieldset>
		            <legend>Thông tin người nhận hàng</legend>
		            <table class="admintable">
			            <tbody>
            			
			            <tr>
				            <td class="key">Tên người nhận</td>
				            <td><%= Html.Encode(Model.Order.ReFullName) %></td>
			            </tr>
			            <tr>
				            <td class="key">Điện thoại</td>
				            <td><%= Html.Encode(Model.Order.RePhone) %></td>
			            </tr>
			            <tr>
				            <td class="key">Email khách hàng</td>
				            <td><%= Html.Encode(Model.Order.ReEmail) %></td>
			            </tr>
			            <tr>
				            <td class="key">Địa chỉ khách hàng</td>
				            <td><%= Html.Encode(Model.Order.ReAddress) %></td>
			            </tr>			
			            </tbody>
		             </table>
	             </fieldset>	        
	        </td>
	    </tr>
	 </table>
	 <fieldset>
        <legend>Danh sách sản phẩm đặt mua</legend>
        <table class="adminlist">
            <tr>
                <th width="30">STT</th>
                <th>Tên sản phẩm</th>
                <th width="150">Số lượng</th>
                <th width="150">Đơn giá</th>
                <th width="150">Thành tiền</th>
            </tr>
            <%var index = 1;
            foreach (var item in Model.Order.OrderDetails) { %>
              <tr>
                  <td><%=index++ %></td>
                  <td><%=item.Product.Name %></td>
                  <td><%=item.Quantity %></td>
                  <td style="text-align:right;"><%=string.Format("{0:0,0.0}",item.Price) %> </td>  
                  <td style="text-align:right;"><%=string.Format("{0:0,0.0}",item.Price*item.Quantity) %> </td>                
              </tr>
             <% } %>
             <tr>
                <td colspan="2" align="right">Tổng</td>
                <td><strong><%=Model.Order.OrderDetails.Sum(e=>e.Quantity)%></strong></td>
                <td></td>
                <td style="text-align:right;" >
					<%var total =Model.Order.OrderDetails.Sum(e => e.Price * e.Quantity); %>
                   <strong><%=string.Format("{0:0,0.0}",total) %> </strong>                      
				</td>
             </tr>
             <tr>               
                <td colspan="4" style="text-align:right;"><strong>Phí chuyển hàng</strong> </td>
                <td style="text-align:right;" >
                   <strong><%=Model.Order.ShippingValue.HasValue? string.Format("{0:0,0.0}",Model.Order.ShippingValue):"0" %> </strong>                      
				</td>
             </tr>
             <tr>               
                <td colspan="4" style="text-align:right;"><strong>Tổng giá trị đơn hàng</strong> </td>
                <td style="text-align:right;" >
					<%var totalAll =Model.Order.TotalValue.HasValue? Model.Order.TotalValue.Value: Model.Order.OrderDetails.Sum(e => e.Price * e.Quantity); %>
                   <strong><%=string.Format("{0:0,0.0}", totalAll)%> </strong>                      
				</td>
             </tr>
        </table>
     </fieldset>
<% } %>
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Message" runat="server">
    <%=ViewData["MessageInfo"]!=null? "<p class='perror'>"+Html.Encode(ViewData["MessageInfo"])+"</p>":string.Empty%>  
</asp:Content>
